package com.zthz.douxing.utils
/**
 * Created by gengjet on 3/20/14.
 */
class ValidateConstanst {

    static def MobileNoPattern = /^1(3|4|5|8)\d{9}$/

    static def IdNoPattern = /^(\d{15})|(\d{17}([0-9]|X))$/

    static def fetchDataTypePattern = /^((weather)|(pm25)){1}$/

    static def fetchDataDatePattern = /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/

    static def fetchDataCodePattern = /^(10[0-9])[0-9]{6}$/

    static def fileTypePattern = /((img)|(ico)|(log)|(png)|(jpg)|(jpeg)|(txt)){1}/

    static def idType = /((ID)|(OTHER)|(PASSPORT)){1}/


    static def password = {
        value->

        if(value instanceof Number)

            value+=""

         if(value.length()<6)
             return "command.passowrd.length"
    }

    static def password2 = {
        value,command->

            if(!value.equals(command.password))

                return "command.password2.nosame"

    }

    static def MobileNo = {

        value,command->

            if(!value ==~ MobileNoPattern)

                return "command.mobileIncorrectFormate"
    }

    static def IDTYPE = {

        value,command->

            def res = value ==~ idType

          if(!res)

              return "command.idType.error"

    }

}